package com.ruoyi.teaching.service.impl;

import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.redis.RedisCache;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.li.work.mapper.SysUserMapper;
import com.ruoyi.teaching.domain.PlatformCCourseLearnTime;
import com.ruoyi.teaching.domain.UniversalCreateUpdate;
import com.ruoyi.teaching.mapper.PlatformCCourseLearnTimeMapper;
import com.ruoyi.teaching.service.PlatformCCourseLearnTimeService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.teaching.utils.UniversalUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author 王旭
 * @since 2025-02-22
 */
@Service
public class PlatformCCourseLearnTimeServiceImpl extends ServiceImpl<PlatformCCourseLearnTimeMapper, PlatformCCourseLearnTime> implements PlatformCCourseLearnTimeService {
    @Autowired
    private PlatformCCourseLearnTimeMapper platformCCourseLearnTimeMapper;
    @Autowired
    private SysUserMapper sysUserMapper;

    @Override
    public AjaxResult addCourseLearnTime(PlatformCCourseLearnTime platformCCourseLearnTime) {
        UniversalCreateUpdate create = UniversalUtil.getCreateUpdate(sysUserMapper);
        platformCCourseLearnTime.setCreateTime(DateUtils.getNowDate());
        platformCCourseLearnTime.setCreateBy(create.getName());
        platformCCourseLearnTime.setCreateId(Long.valueOf(create.getId()));
        int insert = platformCCourseLearnTimeMapper.insert(platformCCourseLearnTime);
        if (insert > 0) {
            return new AjaxResult(200, "添加成功");
        } else {
            return new AjaxResult(500, "添加失败");
        }
    }
}
